package com.qidianit.mes.production.config;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.time.Duration;

/**
 * @author 戴着假发的程序员
 * @company 起点编程
 * @date 2025/7/29 10:51
 * @description
 */
@Configuration
public class RestTemplateConfig {

    @Bean
    //@LoadBalanced // 实现请求的负载均衡
    public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder){
        restTemplateBuilder.setConnectTimeout(Duration.ofMillis(60000));
        restTemplateBuilder.setReadTimeout(Duration.ofMillis(60000));
        return restTemplateBuilder.build();
    }
}
